package com.gvfish.backingbean;

import java.io.UnsupportedEncodingException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

import org.springframework.context.ApplicationContext;
import org.springframework.web.jsf.FacesContextUtils;

import com.gvfish.service.FetchManager;

@ManagedBean
@SessionScoped
public class Test {
	ApplicationContext ctx = FacesContextUtils
	.getWebApplicationContext(FacesContext.getCurrentInstance());
	FetchManager urlFetchManager =(FetchManager)ctx.getBean("fetchManager");
	public String submit(){
//		String r=urlFetchManager.getWiki("绿芽");
//		System.out.println(r);
		System.out.println("test submit");
		return "success";
	}
	
	public static void main(String args[])
	{
		String str = "<span id=\"ctl00_head_LblTitle\"><title>鞍山一条红龙鱼要价36万元 身价堪比一套房_观赏鱼之家</title></span>";
		String regex = "<title>(.*)_观赏鱼之家</title>";
		Pattern p = Pattern.compile(regex);
		Matcher m = p.matcher(str);
		while(m.find()){
//			System.out.println(m.group(1));
		}
		String testString="����Ѷ 09������˹��ҳ���ʼ���캣������ϵ�м���ң���ϵ��Ԥ�ƹ��";
		String a = null;
		try {
			a=new String(testString.getBytes("iso8859-1"),"utf-8");
			System.out.println(new String(testString.getBytes("iso8859-1"),"utf-8"));
			System.out.println(new String(testString.getBytes("iso8859-1"),"gb2312"));
			System.out.println(new String(testString.getBytes("iso8859-1"),"gbk"));
			System.out.println(new String(testString.getBytes("gbk"),"utf-8"));
			System.out.println(new String(testString.getBytes("gbk"),"gb2312"));
			System.out.println(new String(testString.getBytes("gbk"),"iso-8859-1"));
			System.out.println(new String(testString.getBytes("gb2312"),"utf-8"));
			System.out.println(new String(testString.getBytes("gb2312"),"gbk"));
			System.out.println(new String(testString.getBytes("gb2312"),"iso-8859-1"));
			System.out.println(new String(testString.getBytes("utf-8"),"gb2312"));
			System.out.println(new String(testString.getBytes("utf-8"),"gbk"));
			System.out.println(new String(testString.getBytes("utf-8"),"iso-8859-1"));
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(a);
	}
	
}
